package db.dbTables;

import java.sql.ResultSet;
import java.util.List;
import java.util.Objects;

import core.objects.ObjectWithID;
import java.sql.SQLException;

public abstract class AbstractDBTable {

    public static final String COLUMN_NAME = "name";
    
    private String tableName;
    private DbColumn idColumn = null;
    
    public AbstractDBTable(String name) {
        this.tableName = name;
    }

    public String getName() {
        return tableName;
    }
    
    public void setIDColumn(DbColumn id) {
    	this.idColumn = id;
    }

    public DbColumn getIDColumn() {
    	return idColumn;
    }
    
    @Override
    public int hashCode() {
        int hash = 3;
        hash = 97 * hash + Objects.hashCode(this.tableName);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final AbstractDBTable other = (AbstractDBTable) obj;
        if (!Objects.equals(this.tableName, other.tableName)) {
            return false;
        }
        return true;
    }
    
    abstract public List<DbColumn> getDbColumns();
    
    abstract public ObjectWithID convertSqlTableToBaseObject(ResultSet resultSet) throws SQLException;
}